package cn.tanghom.app.web.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.tanghom.framework.system.entity.User;
import cn.tanghom.framework.system.service.ResourcesService;
import cn.tanghom.framework.system.service.UserService;
import cn.tanghom.framework.utils.CommonKey;

/**
 * 首页
 *
 * @author tanghom
 */
@Controller
@RequestMapping("/")
public class IndexController {

    @Resource
    private ResourcesService resourcesService;
    @Resource
    private UserService userService;

    /**
     * main跳转
     *
     * @return
     */
    @RequestMapping("main")
    public String main(HttpServletRequest request, Model model) {
        User userSession = (User) request.getSession().getAttribute(CommonKey.USER_SESSION);
        User loger = userService.getUserById(userSession.getId());
        model.addAttribute("loger", loger);
        return "WEB-INF/jsp/main";
    }

    /**
     * index页
     *
     * @return
     */
    @RequestMapping("index")
    public String index() {
        return "WEB-INF/jsp/index";
    }
}
